-----------------------------------
-- Area: Fei'Yin
-- NPC: Cermet Door (triggers
-- Rukususu dialog)
-- Type: Quest NPC
-- Quests: Curses, Foiled A-Golem!?
-- SMN AF2: Class Reunion, SMN AF3:
-- Carbuncle Debacle
-- Missions: (Windurst) 5-1,7-2,8-2
-- @zone 204
-- @pos -184.500 -1.975 190.000
-----------------------------------
package.loaded["scripts/zones/FeiYin/TextIDs"] = nil;
-----------------------------------

require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/zones/FeiYin/TextIDs");
require("scripts/globals/keyitems");

-----------------------------------
-- onTrade Action
-----------------------------------

function onTrade(player,npc,trade)
end;

-----------------------------------
-- onTrigger Action
-----------------------------------

function onTrigger(player,npc)

	-- Curses, Foiled A_Golem!?
	if(player:hasKeyItem(SHANTOTTOS_NEW_SPELL)) then
		player:startEvent(0x000E); -- deliver spell
	elseif(player:hasKeyItem(SHANTOTTOS_EXSPELL)) then
		player:startEvent(0x000D); -- spell erased, try again!

	-- standard dialog
	else
		player:startEvent(0x000f); 
	end
	return 1;
end;

-----------------------------------
-- onEventUpdate
-----------------------------------

function onEventUpdate(player,csid,option)
	-- printf("CSID: %u",csid);
	-- printf("RESULT: %u",option);
end;

-----------------------------------
-- onEventFinish
-----------------------------------

function onEventFinish(player,csid,option)
	-- printf("CSID: %u",csid);
	-- printf("RESULT: %u",option);

	-- Curses, Foiled A_Golem!?
	if(csid == 0x000E) then
		player:setVar("foiledagolemdeliverycomplete",1);
		player:delKeyItem(SHANTOTTOS_NEW_SPELL); -- remove key item
	end
end;
